package com.getpebble.android.framework.protocol.inbound;

import com.getpebble.android.R;
import com.getpebble.android.bluetooth.protocol.ProtocolMessage;
import com.getpebble.android.framework.protocol.EndpointId;
import com.sun.mail.imap.protocol.ListInfo;
import com.sun.mail.smtp.SMTPMessage;

public abstract class PblInboundAppInstallMessage extends PblInboundMessage {

    static /* synthetic */ class AnonymousClass1 {
        static final /* synthetic */ int[] $SwitchMap$com$getpebble$android$framework$protocol$inbound$PblInboundAppInstallMessage$AppInstallResponseType = new int[AppInstallResponseType.values().length];

        static {
            try {
                $SwitchMap$com$getpebble$android$framework$protocol$inbound$PblInboundAppInstallMessage$AppInstallResponseType[AppInstallResponseType.APP_BANK_INFO.ordinal()] = 1;
            } catch (NoSuchFieldError e) {
            }
            try {
                $SwitchMap$com$getpebble$android$framework$protocol$inbound$PblInboundAppInstallMessage$AppInstallResponseType[AppInstallResponseType.APP_RESULT.ordinal()] = 2;
            } catch (NoSuchFieldError e2) {
            }
            try {
                $SwitchMap$com$getpebble$android$framework$protocol$inbound$PblInboundAppInstallMessage$AppInstallResponseType[AppInstallResponseType.APP_LIST.ordinal()] = 3;
            } catch (NoSuchFieldError e3) {
            }
            try {
                $SwitchMap$com$getpebble$android$framework$protocol$inbound$PblInboundAppInstallMessage$AppInstallResponseType[AppInstallResponseType.APP_INFO.ordinal()] = 4;
            } catch (NoSuchFieldError e4) {
            }
            try {
                $SwitchMap$com$getpebble$android$framework$protocol$inbound$PblInboundAppInstallMessage$AppInstallResponseType[AppInstallResponseType.CURRENT_APP.ordinal()] = 5;
            } catch (NoSuchFieldError e5) {
            }
        }
    }

    public enum AppInstallResponseType {
        APP_BANK_INFO((byte) 1),
        APP_RESULT((byte) 2),
        APP_LIST((byte) 5),
        APP_INFO((byte) 6),
        CURRENT_APP((byte) 7),
        UNKNOWN((byte) -1);
        
        private final byte mCode;

        private AppInstallResponseType(byte code) {
            this.mCode = code;
        }

        public byte getCode() {
            return this.mCode;
        }

        public static AppInstallResponseType fromCode(byte code) {
            for (AppInstallResponseType response : values()) {
                if (response.getCode() == code) {
                    return response;
                }
            }
            return UNKNOWN;
        }
    }

    public abstract AppInstallResponseType getResponseType();

    protected PblInboundAppInstallMessage(ProtocolMessage message) {
        super(message);
    }

    EndpointId getId() {
        return EndpointId.APP_INSTALL_MANAGER;
    }

    protected void checkResponseType(byte responseCode) {
        if (!AppInstallResponseType.fromCode(responseCode).equals(getResponseType())) {
            throw new IllegalArgumentException(getClass().getSimpleName() + "'s type must be " + getResponseType());
        }
    }

    public static PblInboundAppInstallMessage createMessage(ProtocolMessage message) {
        switch (AnonymousClass1.$SwitchMap$com$getpebble$android$framework$protocol$inbound$PblInboundAppInstallMessage$AppInstallResponseType[AppInstallResponseType.fromCode(message.getDataBuffer().get()).ordinal()]) {
            case SMTPMessage.RETURN_FULL /*1*/:
                return new PblInboundAppBankInfoInstallMessage(message);
            case SMTPMessage.RETURN_HDRS /*2*/:
                return new PblInboundAppResultInstallMessage(message);
            case ListInfo.INDETERMINATE /*3*/:
                return new PblInboundAppListInstallMessage(message);
            case SMTPMessage.NOTIFY_DELAY /*4*/:
                return new PblInboundAppInfoInstallMessage(message);
            case R.styleable.WalletFragmentStyle_maskedWalletDetailsHeaderTextAppearance /*5*/:
                return new PblInboundAppCurrentInstallMessage(message);
            default:
                return null;
        }
    }
}
